package zjh_20230330;

import java.io.*;
import java.nio.charset.Charset;
public class practise02 {
    public static void main(String[] args) {
        try(FileReader fileReader = new FileReader("D:\\kaifamiao\\io-text\\practise-01-1.txt", Charset.forName("UTF-8"));
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            FileWriter fileWriter = new FileWriter("D:\\kaifamiao\\io-text\\practise-02-gbk.txt",Charset.forName("gbk"));
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {

            String s;
            while ((s=bufferedReader.readLine())!=null){
                bufferedWriter.write(s);
                bufferedWriter.newLine();
            }

            System.out.println("UTF-8转GBK完成！请查看");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
